package com.example.qiaoruian.shequ.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.qiaoruian.shequ.LoginActivity;
import com.example.qiaoruian.shequ.R;

/**
 *
 */
public class MyTitle extends FrameLayout {//自定义控件
    private LinearLayout ll_back;
    private TextView tv_title;
    private ImageView iv_item;
    private TextView iv_item1;
    private ImageView iv_item2;
    private ImageView iv_item3;
    private boolean isLogin=false;

    public MyTitle(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TextView getTv_item1() {
        return iv_item1;
    }

    public void setTv_item1(TextView iv_item1) {
        this.iv_item1 = iv_item1;
    }

    private void init(final Context context) {
        LayoutInflater.from(context).inflate(R.layout.mytitlebar, this, true);
        tv_title = (TextView) findViewById(R.id.tv_title);
        iv_item = (ImageView) findViewById(R.id.iv_item);
        iv_item1 = (TextView)findViewById(R.id.tv_item1);
        iv_item2 = (ImageView) findViewById(R.id.iv_item2);
        iv_item3 = (ImageView) findViewById(R.id.iv_item3);
        iv_item.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!isLogin){
                    Intent intent=new Intent(context,LoginActivity.class);
                    context.startActivity(intent);
                }
            }
        });
        iv_item2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((Activity) context).finish();
            }
        });
    }

    public MyTitle(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }


    public LinearLayout getLl_back() {
        return ll_back;
    }

    public void setLl_back(LinearLayout ll_back) {
        this.ll_back = ll_back;
    }

    public TextView getTv_title() {
        return tv_title;
    }

    public void setTv_title(TextView tv_title) {
        this.tv_title = tv_title;
    }

    public ImageView getIv_item2() {
        return iv_item2;
    }

    public ImageView getIv_item() {
        return iv_item;
    }

    public void setIv_item(ImageView iv_item) {
        this.iv_item = iv_item;
    }

    public MyTitle(Context context) {
        super(context);
        init(context);

    }

}
